<?php include("../Service/WebClass/report/CampaignClass.php");
$campaign = new Campaign;
$campaign->MyTask();
?>	



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- DW6 -->
<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<title>キャンペーン別集計分析</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="../css/common.css" type="text/css" />
<link href="../css/calendar.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="../js/common.js" type="text/javascript"></script>
<script language="JavaScript" src="../js/Calendar4.js" type="text/javascript"></script>	
<script>
function do_csv()
{
	document.getElementById("act").value = "csv";
	document.getElementById("mainform").submit();	
}
function do_search()
{
    if(document.getElementById("search_detail").style.display != "none")
	{
        if(checkFilter() == false)
		{
			alert("整数値を入力してください。");
			return false;
		}		
	}
	document.getElementById("act").value = "submit";
	// 詳細検索状態をセットする
	if(document.getElementById("search_detail").style.display == "none")
	{
		// 詳細検索は非表示の場合
		document.getElementById("search_detail_hid").value = "display:none";
	}
	else
	{
		// 詳細検索は表示の場合
		document.getElementById("search_detail_hid").value = null;
	}
	document.getElementById("mainform").submit();		
}

function checkFilter()
{
	var regexs = /^[1-9]+[0-9]*$/;
	if(document.getElementById("filter_value").value != "" && document.getElementById("filter_value").value != "")
	{
        var result1 = regexs.test(document.getElementById("filter_value").value);
		if(result1 == false)
		{
			return false;
		}		
	}
	if(document.getElementById("filter3_value").value != "" && document.getElementById("filter3_value").value != "")
	{
		var result3 = regexs.test(document.getElementById("filter3_value").value);
		if(result3 == false)
		{
			return false;
		}
	}
	return true;
}

function do_delete_update(mod)
{
	var isCheck = false;
	var campaignIdCheck = document.getElementsByName("sel");
	var campaignIdList="0";
	for(i=0;i<campaignIdCheck.length;i++)
	{
		if(campaignIdCheck[i].checked == true)
		{
			campaignIdList = campaignIdList + "," + campaignIdCheck[i].value;				
			isCheck = true;
		}
	}
	if(isCheck)
	{
		document.getElementById("campaignIdList").value = campaignIdList;
		if(mod == "delete")
		{
			document.getElementById("act").value = "delete";
			document.getElementById("mainform").submit();			
		}
		else
		{
			window.open("campUpdAll.php?campaignIds=" + campaignIdList);
		}
	}
	else
	{
		alert("キャンペーンを選択してください。");
		return false;
	}
}

function newCamp()
{
	var listingType = document.getElementById("search_media_select").value;
	var listingName = document.getElementById("search_media_select").options[document.getElementById("search_media_select").selectedIndex].text;
	var url = "campNew.php?listingType=" + listingType + "&listingName=" + listingName;
	window.open(url);	
}
</script>

</head>
<body bgcolor="#F4FFE4">
<?php include("../head.php");?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">

 <tr>
    <td width="165" valign="top" bgcolor="#5C743D"><?php include("../menu.php");?>
    <div class="sidemenu1">表示形式</div>
<form name="mainform" id="mainform" method="post">
<input type=hidden id="nowPage" name="nowPage" value="1">
<input type=hidden id="campaignIdList" name="campaignIdList">			
<div class="sidemenu4">
	<input name="report_axis" id="axis_id" value="id" type="radio" onclick="javascript:document.getElementById('nowPage').value = 1;do_search();"><label for="axis_id">キャンペーン別</label><br>
	<input name="report_axis" id="axis_d" value="d" type="radio" onclick="javascript:document.getElementById('nowPage').value = 1;do_search();"><label for="axis_d">日別</label><br>	
	<input name="report_axis" id="axis_w" value="w" type="radio" onclick="javascript:document.getElementById('nowPage').value = 1;do_search();"><label for="axis_w">週別</label><br>
	<input name="report_axis" id="axis_dow" value="dow" type="radio" onclick="javascript:document.getElementById('nowPage').value = 1;do_search();"><label for="axis_dow">曜日別</label><br>
	<input name="report_axis" id="axis_m" value="m" type="radio" onclick="javascript:document.getElementById('nowPage').value = 1;do_search();"><label for="axis_m">月別</label><br>
	<script>
	var list = document.getElementsByName("report_axis");
	var i;
	for(i=0;i<list.length;i++)
	{
		if(list[i].value == "<?php echo $campaign->reportAxis;?>")
		{
			list[i].checked = true;
			break;
		}
	}
	</script>
</div>
    </td>
    <td width="813" colspan="2" align="center" valign="top">
<?php
echo "<input type=hidden name=act id=act value=submit>"
?>
<!-- search_area start -->
<table width="100%" border="0" cellpadding="4" cellspacing="0" class="tbl where">
	<tr>
		<td>

<input type="text" name="from_date" id="cal_input_from" value="<?php echo $campaign->fromDate;?>" class="txBox" style="width: 65px;">
<a href="javascript:void(0)" onclick="if(self.gfPop)gfPop.fPopCalendar(getObjById('cal_input_from'));return false;" HIDEFOCUS>
<img name="popcal2" align="top" src="../images/cal.gif" border="0" alt="calendar" onclick="MyCalendar.SetDate(this,document.getElementById('cal_input_from'))"></a>
-
<input type="text" name="to_date" id="cal_input_to" value="<?php echo $campaign->toDate;?>" class="txBox" style="width: 65px;">
<a href="javascript:void(0)" onclick="if(self.gfPop)gfPop.fPopCalendar(getObjById('cal_input_to'));return false;" HIDEFOCUS>
<img name="popcal2" align="top" src="../images/cal.gif" border="0" alt="calendar" onclick="MyCalendar.SetDate(this,document.getElementById('cal_input_to'))"></a>
&nbsp;&nbsp;

<input type="button" class="btn search" value="" onclick="javascript:document.getElementById('nowPage').value = 1;do_search();">
				&nbsp;&nbsp;
			<input type="button" class="btn btn_wider" value="▼詳細検索..." onclick="openCloseSearchDetail();">
		</td>
	</tr>
	<tr id="search_detail" style="<?php echo $campaign->searchDetailHid?>">
	<input type=hidden name=search_detail_hid id=search_detail_hid>
		<td>
	<select name="search_col" id="search_col" class="txBox">
	<option value="id" >キャンペーンID
	<option value="name" selected>キャンペーン名
	</select>
<script>document.getElementById("search_col").value = "<?php echo $campaign->searchCol;?>";</script>		
<input type="text" name="search_text" size="35" maxlength="100" value="<?php echo $campaign->searchText;?>" class="txBox">
<select name="search_type" id=search_type class="txBox">
	<option value="0">全部一致
	<option value="1" >部分一致
</select>
<script>document.getElementById("search_type").value = "<?php echo $campaign->searchType?>";</script>	
&nbsp;&nbsp;<br><img src="../images/spacer.gif" width="1" height="5" border="0"><br>
<select name="filter_col" id="filter_col" class="txBox">

				<option value="impression" >Imp
				<option value="clickCnt" >Click
				<option value="ctr" >CTR[%]
				<option value="cpc" >CPC[円]
				<option value="cost" >コスト[円]
				<option value="cv" >CV
				<option value="cvr" >CVR[%]
				<option value="cpa" >CPA[円]
				<option value="cpm" >CPM[円]
				<option value="roas" >ROAS[円]
				<option value="sales" >売上[円]
				<option value="salesValue" >売上単価[円]
				<option value="directCvCnt" >直接
				<option value="indirectCvCnt" >間接
				<option value="asistCvCnt" >アシスト
				<option value="postCvCnt" >ポスト効果
			  </select>
			<script>document.getElementById("filter_col").value = "<?php echo $campaign->filterCol;?>";</script>
<input type="text" name="filter_value" id="filter_value" size="10" maxlength="10" value="<?php echo $campaign->filterValue;?>" class="txBox">
<select name="filter_type" id="filter_type" class="txBox">
	<option value="1" >以上
	<option value="2" >以下
</select>
<script>document.getElementById("filter_type").value = "<?php echo $campaign->filterType;?>";</script>
&nbsp;&nbsp;
<select name="filter3_col" id="filter3_col" class="txBox">
				<option value="impression" >Imp
				<option value="clickCnt" >Click
				<option value="ctr" >CTR[%]
				<option value="cpc" >CPC[円]
				<option value="cost" >コスト[円]
				<option value="cv" >CV
				<option value="cvr" >CVR[%]
				<option value="cpa" >CPA[円]
				<option value="cpm" >CPM[円]
				<option value="roas" >ROAS[円]
				<option value="sales" >売上[円]
				<option value="salesValue" >売上単価[円]
				<option value="directCvCnt" >直接
				<option value="indirectCvCnt" >間接
				<option value="asistCvCnt" >アシスト
				<option value="postCvCnt" >ポスト効果
			  </select>
<script>document.getElementById("filter3_col").value = "<?php echo $campaign->filter3Col;?>";</script>
<input type="text" name="filter3_value" id="filter3_value" size="10" maxlength="10" value="<?php echo $campaign->filter3Value;?>" class="txBox">
<select name="filter3_type" id="filter3_type" class="txBox">
	<option value="1" >以上
	<option value="2" >以下
</select>
<script>document.getElementById("filter3_type").value = "<?php echo $campaign->filter3Type;?>";</script>
&nbsp;&nbsp;
<br><img src="../images/spacer.gif" width="1" height="5" border="0"><br>
媒体
<select name="search_media_select" id="search_media_select" onchange="javascript:document.getElementById('nowPage').value = 1;do_search();" class="txBox">
	<option value="0">(指定なし)
	<?php echo $campaign->mediaOptionList;
	?>
</select>
<script>document.getElementById("search_media_select").value = "<?php echo $campaign->searchMediaSelect;?>"</script>
&nbsp;&nbsp;同期状態

<select name="search_sync" id="search_sync" onchange="javascript:document.getElementById('nowPage').value = 1;do_search();" class="txBox">
	<option value="0">(指定なし)
	<option value="2" >更新待ち
	<option value="1" >同期済
	<option value="3" >エラー
</select>
<script>document.getElementById("search_sync").value = "<?php echo $campaign->searchSync;?>"</script>
&nbsp;&nbsp;		</td>
	</tr>
</table>
<span id="backMedia" style="display:none;">
<a href="javascript:var id=document.getElementById('search_media_select').value;var fromDate=document.getElementById('cal_input_from').value;var toDate=document.getElementById('cal_input_to').value;window.location='media.php?listingType='+ id + '&fromDate='+fromDate+'&toDate='+toDate;">
<img src="../images/branch_parent.gif" border=0>媒体別に戻る</a><br>
</span>			
<!-- search_area end -->
<img src="view/images/spacer.gif" width="1" height="5" border="0"><br>

<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tbl_clear">
	<tr height="30" valign="bottom">

		<td align="left">
			<img src="../images/ico_graph_line.gif" border="0">
						種類
			<select name="graph_type" id="graph_type" size="1" class="txBox" onchange="do_search();">
				<option value="0">折れ線
				<option value="1" >分布図			
			</select>
			<script>document.getElementById("graph_type").value = "<?php echo $campaign->graphType;?>"</script>
			&nbsp;
			指標1
			<select name="graph_col1" id="graph_col1" size="1" class="txBox" onchange="do_search();">
				<option value="impression" >Imp
				<option value="clickCnt">Click
				<option value="ctr" >CTR[%]
				<option value="cpc" >CPC[円]
				<option value="cost" >コスト[円]
				<option value="cv" >CV
				<option value="cvr" >CVR[%]
				<option value="cpa" >CPA[円]
				<option value="cpm" >CPM[円]
				<option value="roas" >ROAS[円]
				<option value="sales" >売上[円]
				<option value="salesValue" >売上単価[円]
				<option value="clickCvSpan" >Click-CV間隔[秒]
				<option value="directCvCnt" >直接
				<option value="indirectCvCnt" >間接
				<option value="asistCvCnt" >アシスト
				<option value="postCvCnt" >ポスト効果
			  </select>
			  <script>document.getElementById("graph_col1").value = "<?php echo $campaign->graphCol1;?>"</script>
			&nbsp;
			指標2
			<select name="graph_col2" id="graph_col2" size="1" class="txBox" onchange="do_search();">
				<option value="impression" >Imp
				<option value="clickCnt" >Click
				<option value="ctr" >CTR[%]
				<option value="cpc" >CPC[円]
				<option value="cost" >コスト[円]
				<option value="cv">CV
				<option value="cvr" >CVR[%]
				<option value="cpa" >CPA[円]
				<option value="cpm" >CPM[円]
				<option value="roas" >ROAS[円]
				<option value="sales" >売上[円]
				<option value="salesValue" >売上単価[円]
				<option value="clickCvSpan" >Click-CV間隔[秒]
				<option value="directCvCnt" >直接
				<option value="indirectCvCnt" >間接
				<option value="asistCvCnt" >アシスト
				<option value="postCvCnt" >ポスト効果
			  </select>
			  <script>document.getElementById("graph_col2").value = "<?php echo $campaign->graphCol2;?>"</script>
						&nbsp;&nbsp;
			グラフサイズ
			<select name="graph_size" size="1" id="graph_size" class="txBox" onchange="do_search();">
				<option value="0">標準
				<option value="1" >最大
				<option value="2" >非表示
			</select>
			<script>document.getElementById("graph_size").value = "<?php echo $campaign->graphSize;?>"</script>		
		</td>
		<td align="right">
		<input type="button" class="btn_exp csv" title="CSV出力" value="" onclick="do_csv()"></td>
	</tr>
</table>
<div id="chart_area">
<?php
	// 初期化の場合、図は表示しない
	if($campaign->graphSize == "2")
	{
	}
	else
	{
		$src = "../Service/Graph/report/CampaignGraph.php?reportAxis=".$campaign->reportAxis."&fromDate=".$campaign->fromDate;
		$src = $src."&toDate=".$campaign->toDate."&uniqType=".$campaign->uniqType."&tactic=".$campaign->tactic."&searchDetail=".$campaign->searchDetailHid;
		$src = $src."&searchCol=".$campaign->searchCol."&searchText=".urlencode(trim($campaign->searchText))."&searchType=".$campaign->searchType;
		$src = $src."&filterCol=".$campaign->filterCol."&filterValue=".$campaign->filterValue."&filterType=".$campaign->filterType;
		$src = $src."&filter3Col=".$campaign->filter3Col."&filter3Value=".$campaign->filter3Value."&filter3Type=".$campaign->filter3Type;
		$src = $src."&searchMediaSelect=".$campaign->searchMediaSelect."&searchSync=".$campaign->searchSync."&graphType=".$campaign->graphType;
		$src = $src."&graphCol1=".$campaign->graphCol1."&graphCol2=".$campaign->graphCol2."&graphSize=".$campaign->graphSize."&showDeleted=".$campaign->showDeleted."&selectPoint=".$campaign->selectPoint;
		$src = $src."&nowPageNum=".$campaign->nowPageNum;
		// 検索結果がない場合
		//if($campaign->searchResult != null)
		//{
			//echo $src;
			echo "<img id=graph src=".$src.">";
		//}		
	}
?>
</div>
<br>

<table width="100%" border="0" cellpadding="2" cellspacing="1">
	<tr>

		<td align="left">
			<img src="../images/ico_summary.gif" border="0">
ビュー
<select name="select_view" size="1" id="select_view" class="txBox" onchange="javascript:document.getElementById('nowPage').value = 1;do_search();">
	<option value="1">標準ビュー
	<option value="2" >コスト分析
	<option value="4" >コンバージョン
</select>
<script>document.getElementById("select_view").value = "<?php echo $campaign->selectView;?>"</script>		
&nbsp;&nbsp;

成果地点
<select name="select_point" id=select_point size="1" class="txBox" onchange="javascript:document.getElementById('nowPage').value = 1;do_search();">
	<option value="0">(すべて)
	<?php
	echo $campaign->cvPointList;
	?>
	</select>
	<script>document.getElementById("select_point").value = <?php echo $campaign->selectPoint; ?>;</script>

&nbsp;&nbsp;


	<input type="checkbox" name="show_deleted" value="1" id="show_deleted"  >
	<?php if($_POST["show_deleted"] == "1")
		{
			echo "<script>document.getElementById('show_deleted').checked = true;</script>";
		}
	?>
<label for="show_deleted">削除済みも表示</label>		</td>
		<td align="right" width="105px">								
		<span id="showBtnSpn" style="display:none">			
		<input class="btn new" id="newCampBtn" onclick="newCamp()" type="button">
		<input type="button" id="updateAllCmapBtn" class="btn" value="一括更新" onclick="do_delete_update('update');">
		</span>						
		</td>
		<td align="left" width="50px">
		<input type="button" class="btn refresh" onclick="do_search();">
		</td>
		<td align="left">
		<span id="showDeleteBtn" style="display:none">
		<input type="button" id="delCampBtn" class="btn del" onclick="do_delete_update('delete');">
		</span>
		</td>				
	</tr>
</table>
<script>
// 非指定なしの場合		
if(document.getElementById("search_media_select").value != "0")
{
	document.getElementById("backMedia").style.display = "block";
	if(document.getElementById("axis_id").checked == true)
	{
		document.getElementById("showBtnSpn").style.display = "block";
	}

}

if(document.getElementById("axis_id").checked == true)
{
	document.getElementById("showDeleteBtn").style.display = "block";
}		
</script>
<table width="100%" border="0" cellpadding="4" cellspacing="0" class="tbl">
<tr align="right" class="tr2">
<?php echo $campaign->tableList;?>
</table>

<table width="100%" border="0" cellpadding="2" cellspacing="0">
<tr align="right"> 
<td align="right">
<?php echo "<label id='fromToPage' name='fromToPage'>".$campaign->fromToRowHtml."</label>";?>     
<?php echo "<label id='memberInfoCount' name='memberInfoCount'>".$campaign->allRowHtml."</label>";?>
</td><td>
<?php echo $campaign->pageLinkHtml;?>
</td>  
</tr>
</table>
<br>
</form>	
    <br />
    <br />
    </td>
  </tr>
 </table>
<?php
include("../foot.php");
?>
</body>
</html>
